package com.feib.stms.batch.service;

import java.io.Serializable;
import java.util.Date;
import java.util.List;


import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.feib.stms.batch.dao.DeliveryPaymentChkSumMQJdbcDao;
import com.feib.stms.batch.domain.DeliveryPaymentChkSum;
import com.feib.stms.batch.domain.UploadFile;

@Service("deliveryPaymentChkSumMQService")
public class DeliveryPaymentChkSumMQService implements Serializable{


	private static final long serialVersionUID = -9023051718576167474L;

	protected Logger logger = LoggerFactory.getLogger(this.getClass());

	@Resource(name="deliveryPaymentChkMQSumJdbcDao")
	private DeliveryPaymentChkSumMQJdbcDao deliveryPaymentChkSumJdbcDao;
	
	
	
	public List<UploadFile> queryToDoChkUploadFile(Date nextBussinessDay, boolean firstTime){
				
		return this.deliveryPaymentChkSumJdbcDao.queryToDoChkUploadFile(nextBussinessDay, firstTime);
		
	}
	
	public Date getNextBusinessDay(Date day){
		
		return this.deliveryPaymentChkSumJdbcDao.getNextBusinessDay(day);
	}
	

	/**
	 * 檔案明細中，驗資尚未通過的總筆數
	 * @param uploadFilePk 驗資檔PK
	 * @return
	 */
	public int countAllToDoRecords(Long uploadFilePk) {
		
		return this.deliveryPaymentChkSumJdbcDao.countAllToDoRecords(uploadFilePk);
	}
	
	
	/**
	 * 取得待處理的明細
	 * @param uploadFilePk 驗資檔案PK
	 * @param begIdx 待處理紀錄 起始
	 * @param endIdx 待處理紀錄 結束
	 * @return
	 */
	public List<DeliveryPaymentChkSum> findToDoRecords(Long uploadFilePk, int begIdx,int endIdx) {
		
		return this.deliveryPaymentChkSumJdbcDao.getToDoRecords(uploadFilePk, begIdx, endIdx);
	}

	
	public int updateUploadFileFileStatus(UploadFile uploadFile){
		
		return  this.deliveryPaymentChkSumJdbcDao.updateUploadFileFileStatus(uploadFile);
	};
	
	
	public int updateDeliveryPaymentChkSum(DeliveryPaymentChkSum deliveryPaymentChkSum) {
		
		return  this.deliveryPaymentChkSumJdbcDao.updateDeliveryPaymentChkSum(deliveryPaymentChkSum);
	
	};
}
